a, b, c = map(str, input().split())

right = True



word = ""

numbers = {
    "zero" : 0,
    "one" : 1,
    "two" : 2,
    "three" : 3,
    "four" : 4,
    "five" : 5,
    "six" : 6,
    "seven" : 7,
    "eight" : 8,
    "nine" : 9
    }

def is_prime(n):
    if n < 2:
        return False
    for i in range(2, n):
        if n % i == 0:
            return False
    return True

def nearest_prime(n):
    if is_prime(n):
        return n
    
    lower = n
    upper = n
    
    while True:
        if is_prime(lower):
            return lower
        if is_prime(upper):
            return upper
        lower -= 1
        upper += 1


if a in numbers.keys():
    word += str(numbers[a])
elif right:
    right = False
    print("Wrong input")
if b in numbers.keys() and right:
    word += str(numbers[b])
elif right:
    right = False
    print("Wrong input")
if c in numbers.keys() and right:
    word += str(numbers[c])
elif right:
    right = False
    print("Wrong input")

if len(word) == 3:
    print(nearest_prime(int(word)))